﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AmkeniCrossLoginApplication.Data_Access;

namespace Amkeni_System.CO.Edit
{
    public partial class NewCall : System.Web.UI.Page
    {
        Amkeni_DatabaseEntities db = new Amkeni_DatabaseEntities();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void SaveBtn_Click(object sender, EventArgs e)
        {
            try
            {
                RFP newCall = new RFP();
                newCall.RFP_name = CallNameTxBx.Text.Trim();
                newCall.RFP_description = DefinationTxBx.Text.Trim();
                newCall.budget = decimal.Parse(BudgetTxBx.Text.Trim());
                db.RFPs.Add(newCall);

                error.Text = "Saved";
                error.Visible = true;

                CallGridView.DataBind();
            }
            catch (Exception ex)
            {
                error.Text = "Database Error: " + ex.Message + "<br /> " + ex.StackTrace;
                error.Visible = true;
            }
            finally
            {
                db.SaveChanges();
                CallGridView.DataBind();
            }
        }

        protected void CancelBtn_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Amkeni_System/CO/Call_For_Proposals.aspx", true);
        }
    }
}